Annonymous functions accessing local variables [ActionScript - Flex 3.5]

Posted by Ali on Stack Overflow See other posts from Stack Overflow or by Ali
Published on 2010-06-08T20:23:53Z Indexed on 2010/06/08 21:32 UTC
Read the original article Hit count: 207

Filed under:
|

Hi All, I am having a situation with my actionscript/flex front end.

 for each (var sym:String in ["A","B","C"]) {

                const handler = function (data:Object):void { Alert.show(sym); }                

                asyncCallback(handler);

   }

I am expecting to have 3 Alert windows containing A, B and C. But the actual result is 3 alert windows all showing C !

I appreciate your comments. -A

© Stack Overflow or respective owner

Related posts about flex

Related posts about actionscript-3